package io.gitee.yth.design.pattern.test.core.pattern.behavioral.clainofresponsibility;

/**
 * @author yth
 * @since 2023-05-03-16:03
 */
public abstract class HelpHandler {

    private HelpHandler successor;
    private Topic topic;

    public HelpHandler(HelpHandler successor, Topic topic) {
        this.successor = successor;
        this.topic = topic;
    }

    public HelpHandler(HelpHandler successor) {
        this.successor = successor;
        this.topic = Topic.NO_HELP_TOPIC;
    }

    public boolean hasHelp() {
        return topic != Topic.NO_HELP_TOPIC;
    }

    public void setHandler(HelpHandler successor, Topic topic) {
        this.successor = successor;
        this.topic = topic;
    }

    public void handleHelp() {
        if (successor != null) {
            successor.handleHelp();
        }
    }

}
